package com.wy.jetpack.activity;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.ViewModelProvider;

import com.wy.jetpack.R;
import com.wy.jetpack.databinding.ActivityDatabindingBinding;
import com.wy.jetpack.viewmodel.DataBindingLiveDataVM;

//databinding +livedata +viewmodel
public class DataBindingActivity extends AppCompatActivity {


    private DataBindingLiveDataVM dbldVM;
    //生成命名规则xml名+Binding
    private ActivityDatabindingBinding binding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding= DataBindingUtil.setContentView(this,R.layout.activity_databinding);
        dbldVM = new ViewModelProvider(this).get(DataBindingLiveDataVM.class);
        binding.setData(dbldVM);
        binding.setLifecycleOwner(this);

    }
}
